# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=pueue
pkgver=3.3.2
pkgrel=0
pkgdesc="Manage your shell commands"
url="https://github.com/nukesor/pueue"
# ppc64le, riscv64, s390x: fails to build ring crate
arch="all !ppc64le !riscv64 !s390x"
license="MIT"
checkdepends="bash"
makedepends="cargo cargo-auditable"
subpackages="
	$pkgname-bash-completion
	$pkgname-fish-completion
	$pkgname-zsh-completion
	"
source="https://github.com/Nukesor/pueue/archive/v$pkgver/pueue-$pkgver.tar.gz
	fix-process_helper-tests.patch
	timeout.patch
	"
# FIXME: built with current rust, a testcase segfaults..
options="net !check"


prepare() {
	default_prepare

	cargo fetch --target="$CTARGET" --locked
}

build() {
	cargo auditable build --release --frozen

	mkdir -p target/completion
	local sh; for sh in bash fish zsh; do
		./target/release/pueue completions $sh target/completion/
	done
}

check() {
	# test_multiple_worker - fails on CI, but passes locally
	cargo test --frozen -- \
		--skip daemon::integration::worker_environment_variables::test_multiple_worker
}

package() {
	cd target

	install -D -m755 release/pueue -t "$pkgdir"/usr/bin/
	install -D -m755 release/pueued -t "$pkgdir"/usr/bin/

	install -D -m644 completion/$pkgname.bash "$pkgdir"/usr/share/bash-completion/completions/$pkgname
	install -D -m644 completion/*.fish -t "$pkgdir"/usr/share/fish/vendor_completions.d/
	install -D -m644 completion/_* -t "$pkgdir"/usr/share/zsh/site-functions/
}

sha512sums="
bcba82638b9eac9e1eef21539250ac10e5485a3d53cf575873b33fcc6a2c70f3fbde9cc7b705c409bd814585d2b8c6eb83ac90172966b7f1e9a53b75aae075e1  pueue-3.3.2.tar.gz
a0d855a6353b74babb67c17c496821d0aecf6bea831fa94c4a2b41af08e5d4e80a616b8c9e08989080f44e972cb67b59719431561b1f359471f26c642287a34f  fix-process_helper-tests.patch
9354467f87eac40ee9dcf7dca13ee360077d539cf53ad9bdf6cdbb2031fbfa7fe65cbacfbf1e97a25da59495471bebcfc08bf2c9bfa84764a3d347569af71c5a  timeout.patch
"
